﻿// project      : soapi-notify 
// purpose      : console and growl notifications of new Stack Exchange questions
// source       : http://soapi.info/tools/notify.aspx
// announcement : http://stackapps.com/questions/820
// website      : http://soapi.info/tools/notify.aspx
// license      : MIT/X11 - Copyright (c) 2010 Sky Sanders - See License.txt
// inspiration  : http://stackapps.com/questions/817/senotify-se-new-question-notification
// 
//  
using System;
using System.Collections.Generic;

namespace Soapi.Notify
{
    public static class UnixTimeStampUtility
    {
        #region UnixTimestamp Conversion

        private const string EpochUnderflowMessage = "Unix epoc starts January 1st, 1970";

        public static DateTime FromUnixTime(this Int64 self)
        {
            DateTime ret = new DateTime(1970, 1, 1);
            return ret.AddSeconds(self);
        }

        public static Int64 ToUnixTime(this DateTime self)
        {
            if (self == DateTime.MinValue)
            {
                return 0;
            }

            DateTime epoc = new DateTime(1970, 1, 1);
            TimeSpan delta = self - epoc;

            if (delta.TotalSeconds < 0) throw new ArgumentOutOfRangeException(EpochUnderflowMessage);

            return (long) delta.TotalSeconds;
        }

        #endregion
    }


    [Serializable]
    public class QuestionsResponse
    {
        public int page;
        public int pagesize;
        public List<Question> questions;
        public int total;
    }

    [Serializable]
    public class Question
    {
        public string site { get; set; }
        public List<string> tags { get; set; }
        public int answer_count { get; set; }
        public int accepted_answer_id { get; set; }
        public int favorite_count { get; set; }
        public int bounty_amount { get; set; }
        public string closed_reason { get; set; }
        public string question_timeline_url { get; set; }
        public string question_comments_url { get; set; }
        public string question_answers_url { get; set; }
        public int question_id { get; set; }
        public int up_vote_count { get; set; }
        public int down_vote_count { get; set; }
        public int view_count { get; set; }
        public int score { get; set; }
        public bool community_owned { get; set; }
        public string title { get; set; }
        public string body { get; set; }


        public long bounty_closes_date { get; set; }
        public long closed_date { get; set; }
        public long protected_date { get; set; }
        public long locked_date { get; set; }
        public long creation_date { get; set; }
        public long last_edit_date { get; set; }
        public long last_activity_date { get; set; }
    }
}